package com.stu.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置WebSocket消息队列
 */
@Configuration
public class WebSocketMQConfig {

//    创建直连交换机
    @Bean
    public DirectExchange newCouponDirectExchange(){
        return new DirectExchange("webSocketCouponExchange",true,false);
    }
//    创建队列
    @Bean
    public Queue newCouponQueue(){
        return new Queue("webSocketCouponQueue",true,false,false);
    }
//    二者进行绑定
    @Bean
    public Binding CouponWebsocket(){
        return BindingBuilder.bind(newCouponQueue()).to(newCouponDirectExchange()).with("zhtCoupon");
    }
}
